package com.pp.controller;

import com.pp.common.vo.ImageVO;
import com.pp.common.vo.SysResult;
import com.pp.service.FileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@CrossOrigin
@RequestMapping("/api/file")
public class fileController {

    @Autowired
    private FileService fileService;

    @PostMapping("/uploader")
    public SysResult uploader(MultipartFile file){
        System.out.println(file.getOriginalFilename());
        ImageVO imageVO = fileService.uploader(file);
        if (imageVO==null){
            return SysResult.fail();
        }
        return SysResult.success(imageVO);
    }
}
